<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script type="text/javascript">
    //1.
    let cat={name:'jack',age:10}
    console.log(`1. cat=${cat.name},${cat.age}`)

    //2.
    let name="周星驰"
    let job="演员"
     let person={
        name,
         job,
         show(){
            console.log(`2.  name=${this.name},job=${this.job}`)
         }
     }
     person.show()

    //3.
    var cal={
        oper:"/",
        arr:[1,2,3,5]
    }

    function f2({oper,arr}){
        let res=arr[0]
        if (oper=="/"){
           for(let i=1;i<arr.length;i++){
               res/=arr[i]
           }
        }else if(oper=="+"){
            for(let i=1;i<arr.length;i++){
                res+=arr[i];
            }
        }
        console.log("3.  "+res)
    }
    f2(cal)

    //4.
    let f8=(arr,fun)=>{
        console.log("4.  结果=",fun(arr))
    }
    f8([1,2,3,5],(arr)=>{
        let res=0
        for(let i=0;i<arr.length;i++){
            res+=arr[i];
        }
        return res;
    })

  </script>
</head>
<body>

</body>
</html>